﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace exnet.FileExplorer
{
    /// <summary>
    /// Interaction logic for Main.xaml
    /// </summary>
    public partial class Main : Window
    {
        public Main()
        {
            InitializeComponent();

            _treeControl.TreeView.SelectedItemChanged += TreeView_SelectedItemChanged;
        }

        void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            // update the selection so the ListView displays the TreeNode Children
            Ui.Node node = _treeControl.TreeView.SelectedItem as Ui.Node;
            if (object.ReferenceEquals(null, node)) _listView.ItemsSource = null;
            else _listView.ItemsSource = node.Children;
        }

        public Ui.Tree.TreeControl TreeControl { get { return _treeControl; } }
    }
}
